Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

escape domain regexes #141

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

ds-cbo
Copy link

@ds-cbo ds-cbo commented Jan 5, 2024

Fixes #140

r"https?://codeload.github.com/(?P<namespace>.+)/(?P<name>.+)/"
r"(zip|tar.gz|tar.bz2|tgz)/(.*/)*"
r"https?://codeload\.github\.com/(?P<namespace>.+)/(?P<name>.+)/"
r"(zip|tar\.gz|tar\.bz2|tgz)/([^/]*/)*"
Copy link
Author

@ds-cbo ds-cbo Jan 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason for this change from (.*/)* to ([^/]*/)* can be found here:

https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS

r"((?P=name)(-|@)?)?"
r"(?P<version_prefix>v|V?)(?P<version>.+).(zip|tar.gz|tar.bz2|.tgz)"
r"(?P<version_prefix>v|V?)(?P<version>.+)\.(zip|tar\.gz|tar\.bz2|tgz)"
Copy link
Author

@ds-cbo ds-cbo Jan 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also fixes a bug with tgz files, since it would previously match

v1.2.3.tgz as { version="1.2.", extension=".tgz" }
as opposed to { version="1.2.3", extension="tgz" }

due to the double unescaped . here.

See for clarification: https://regex101.com/r/luaRIy/1

@pombredanne
Copy link
Member

Thanks! do you mind to resolve the conflicts that emerged since so we can merge?

@ds-cbo
Copy link
Author

ds-cbo commented Feb 20, 2024

@pombredanne I've resolved the merge conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

May be vulnerable to npmjs.evil.com, evilpython.org, evilsourceforge.net and more
2 participants